#include "lcd.h"
#include <QDebug>
#include <QTextCodec>

Lcd::Lcd()
{
    lcd_init();
    timer_ = new QTimer(this);
    connect(timer_, SIGNAL(timeout()), this, SLOT(paint()));
    timer_->setInterval(500);
    timer_->start();
}



int Lcd::writeText(QRect rect, const QString &text, Color fontColor, Color backColor)
{

    QByteArray array=text.toLocal8Bit();
    const char * temp = reinterpret_cast< const char*>(array.data());

    /**/

    int x = rect.x(), y = rect.y();
    int len=rect.width();

    int type=1;

    if(fontColor.b>255)
        type=0;


    return lcd_poswrite(temp, x, y,type);
    // return 0;
}

int Lcd::clearRect(QRect rect)
{
    int x1 = rect.x(), y1 = rect.y();
    int x2= x1+rect.width(), y2= y1+rect.height();

    return  lcd_clear_rect( x1, y1,x2, y2);
}


void Lcd::paint()
{


    end() ;
}
int Lcd::clear()
{
    lcd_clear_all() ;
    return 0;
}

